%%
%% This is file `pstricks.sty'.
%%
%% IMPORTANT NOTICE:
%%
%% pstricks.sty Copyright (C) 1997 Timothy Van Zandt
%% pstcol.sty   Copyright (C) 1994-1996 1999 David Carlisle
%% pstricks.sty Copyright (C) 2004-2011 Rolf Niepraschk <Rolf.Niepraschk@gmx.de>
%%                                      Herbert Voss <hvoss@tug.org>
%%
%% This package may be distributed under the terms of the LaTeX Project
%% Public License, as described in lppl.txt in the base LaTeX distribution.
%% Either version 1.0 or, at your option, any later version.
%%

\NeedsTeXFormat{LaTeX2e}

\ProvidesPackage{pstricks}
  [2011/04/23 v0.50 LaTeX wrapper for `PSTricks' (RN,HV)]
% 
\def\documentclass{%
  \edef\@tempa{\jobname.tex }%
  \edef\@tempb{\@filef@und}%
  \@onelevel@sanitize\@tempa
  \@onelevel@sanitize\@tempb
  \ifx\@tempa\@tempb
    \@latex@error
      {`\jobname.tex' is a forbidden name for your document,\MessageBreak
      it is already a name of a package}%
      {Choose another name for your document}\@gobble
  \else
    \@twoclasseserror
  \fi
}
% 
\newif\ifpst@OldVersion\pst@OldVersionfalse
\DeclareOption{97}{\pst@OldVersiontrue}
\newif\ifpst@PDF\pst@PDFfalse
\DeclareOption{pdf}{\global\pst@PDFtrue}
%------------------------------------ PLAIN --------------------------------
\DeclareOption{plain}{%
  \ifpst@OldVersion
    \def\psDEBUG[#1]#2{}%
    \def\pst@tempa{pstricks97.tex}%
  \else
    \def\pst@tempa{pstricks.tex}%
  \fi
  \input{\pst@tempa}%
  \ProvidesFile{\pst@tempa}[\filedate\space v\fileversion\space `PSTricks' (tvz)]%
  \endinput
}

\DeclareOption*{\OptionNotUsed}

\ProcessOptions\relax

\ifpst@PDF
   \typeout{>>> Loading package auto-pst-pdf <<<}
   \AtBeginDocument{\usepackage{auto-pst-pdf}}%
  \ifnum\pdfshellescape=\@ne\else
    \PackageWarningNoLine{pstricks}{%
************************************               \MessageBreak
  Option pdf needs a "pdflatex -shell-escape <file>" \MessageBreak
    or a "pdflatex -enable-write18 <file>"           \MessageBreak
    (if you are using MikTeX)                        \MessageBreak  
************************************}
  \fi
\fi

\RequirePackage{ifpdf,ifluatex}

\AtBeginDocument{%
  \ifpdf
    \ifluatex
      \def\pst@tempA{lualatex} 
    \else
      \def\pst@tempA{pdflatex}
    \fi
    \@ifpackageloaded{pst-pdf}{}{%
      \@latex@error{%
        You have run the document with pdflatex, but PSTricks\MessageBreak
        requires latex->dvips->ps2pdf or alternatively the use\MessageBreak
        of the package `auto-pst-pdf'. Then you can run\MessageBreak
        \space\space`\pst@tempA\space -shell-escape <file>' (TeX Live)
        \MessageBreak or\MessageBreak
        \space\space`\pst@tempA\space -enable-write18 <file>' (MikTeX)}%
        {See also the PSTricks web pages http://PSTricks.tug.org}}%
  \fi
}

\@ifundefined{PSTricksLoaded}
{%
  \let\saved@scalebox\scalebox
  \ifpst@OldVersion
    \def\psDEBUG[#1]#2{}
    \def\pst@tempa{pstricks97.tex}%
  \else
    \def\pst@tempa{pstricks.tex}
  \fi
  \input{\pst@tempa}%
  \ProvidesFile{\pst@tempa}
    [\filedate\space v\fileversion\space `PSTricks' (tvz,hv)]
  \ifpst@OldVersion
    \IfFileExists{pstricks97.pro}{%
      \ProvidesFile{pstricks97.pro}%
        [1998/06/01 v. 97 patch 3,  PostScript prologue file (hv)]
        \@addtofilelist{pstricks97.pro}}{}%
    \IfFileExists{pst-dots97.pro}{%
      \ProvidesFile{pst-dots97.pro}
        [1999/12/16 v. 97 patch 1,  PostScript prologue file (hv)]
        \@addtofilelist{pst-dots97.pro}}{}%
  \else
    \input{pst-fp.tex}
    \ProvidesFile{pst-fp.tex}
      [\filedate\space v\fileversion\space `PST-fp' (hv)]
    \IfFileExists{pstricks.pro}{%
      \ProvidesFile{pstricks.pro}
        [2010/04/24 v. 1.07,  PostScript prologue file (hv)]
        \@addtofilelist{pstricks.pro}}{}%
    \IfFileExists{pst-algparser.pro}{%
      \ProvidesFile{pst-algparser.pro}
        [2008/01/01 v. 0.01,  PostScript prologue file (hv)]
        \@addtofilelist{pst-algparser.pro}}{}%
    \IfFileExists{pst-tools.pro}{%
      \ProvidesFile{pst-tools.pro}
        [2011/04/23 v. 0.01,  PostScript prologue file (hv)]
        \@addtofilelist{pst-tools.pro}}{}%
    \IfFileExists{pst-dots.pro}{%
      \ProvidesFile{pst-dots.pro}
        [2006/12/19 v. 2.00,  PostScript prologue file (hv)]
        \@addtofilelist{pst-dots.pro}}{}%
  \fi
  {%
    \let\psscalebox\scalebox
    \let\psscaleboxto\scaleboxto
  }{}
  \let\scalebox\saved@scalebox
}{}
%
%
\IfFileExists{xcolor.sty}{%
  \def\pst@ColorPackage{xcolor}
%  \PassOptionsToPackage{override}{xcolor}
}{\def\pst@ColorPackage{color}}%

%------------------------------------ DIA --------------------------------
\newif\ifpst@DIA\pst@DIAfalse
\DeclareOption{DIA}{\pst@DIAtrue}
%------------------------------ color or xcolor --------------------------
\DeclareOption{noxcolor}{\def\pst@ColorPackage{color}}
%------------------------------------ VTeX --------------------------------
\DeclareOption{vtex}{%
  \pst@def{setTransparency}< >
  \pst@def{setStrokeTransparency}< >
  \pst@def{setBlendmode}< >%
  \PassOptionsToPackage{vtex}{\pst@ColorPackage}%
}
%---------------------------------DISTILLER --------------------------------
\DeclareOption{distiller}{%
  \pst@def{setTransparency}<
    [ /ca \psk@opacityalpha 
      /CA \psk@opacityalpha /SetTransparency pdfmark >
  \pst@def{setStrokeTransparency}<
    [ /ca \psk@strokeopacityalpha 
      /CA \psk@strokeopacityalpha /SetTransparency pdfmark >
  \pst@def{setBlendmode}<
    [ /BM\ifcase\psk@blendmode%
        /Normal \or	% 0
	/Multiply \or	% 1
	/Screen \or	% 2
	/Overlay \or	% 3
	/Darken \or	% 4
	/Lighten \or	% 5
	/ColorDodge \or	% 6
	/ColorBurn \or	% 7
	/HardLight \or	% 8
	/SoftLight \or	% 9
	/Difference \or	% 10
	/Exclusion \or	% 11
	/Hue \or	% 12
	/Color \or	% 13
	/Saturation \or	% 14
	/Luminosity 	% 15
      \else /Normal \fi
      /ca \psk@shapealpha /CA \psk@opacityalpha /SetTransparency pdfmark >%
}
%---------------------------------COLOR --------------------------------
\DeclareOption*{%
  \PassOptionsToPackage\CurrentOption{\pst@ColorPackage}}
\ProcessOptions\relax

\RequirePackage{\pst@ColorPackage}

\@ifpackageloaded{xcolor}{%
  \@ifpackagelater{xcolor}{2004/05/02}%
  {%
    \let\pst@getcolor\XC@getcolor
    \let\pst@usecolor\XC@usecolor
  }
  {%
    \PackageError{pstricks}{%
    *************************************************\MessageBreak
    * Your Version of `xcolor.sty' is too old!\MessageBreak
    * You need the version from 2004/05/02 or newer\MessageBreak
    * or use: \string\usepackage[noxcolor]{pstricks}\MessageBreak
    *************************************************}{}%
  }%
}{%
  \def\pst@getcolor#1#2{%
    \@ifundefined{\string\color@#1}%
    {\@pstrickserr{Color `#1' not defined}\@eha}%
    {\edef#2{#1}}}%
  \def\pst@usecolor#1{\expandafter\expandafter\expandafter\c@lor@to@ps%
    \csname\string\color@#1\endcsname\@@\space}%
  \definecolor{darkgray}{gray}{.25}
  \definecolor{gray}{gray}{.5}
  \definecolor{lightgray}{gray}{.75}
}%
%
\definecolor{gradbegin}{rgb}{0,1,1}
\definecolor{gradend}{rgb}{0,.1,.95}
%
\@ifundefined{xglobal}%
 {\def\xglobal#1#2#3#4% UK 2005-11-17
   {#1{#2}{#3}{#4}%
    \expandafter\global\expandafter\let\csname\string\color@#2%
    \expandafter\endcsname\csname\string\color@#2\endcsname}}{}%
%
\def\newgray#1{%
  \expandafter\gdef\csname #1\endcsname{\color{#1}}%  HV 2004-03-31
  \xglobal\definecolor{#1}{gray}}%
%
\def\newrgbcolor#1#2{%
  \expandafter\gdef\csname #1\endcsname{\color{#1}}%  HV 2004-03-31
  \edef\@tempa{\noexpand\newrgbcolorx{#1}#2\noexpand\@@}\@tempa}%
\def\newrgbcolorx#1#2 #3 #4\@@{%
  \xglobal\definecolor{#1}{rgb}{#2,#3,#4}}
%
\def\newcmykcolor#1#2{%
  \expandafter\gdef\csname #1\endcsname{\color{#1}}%  HV 2004-03-31
  \edef\@tempa{\noexpand\newcmykcolorx{#1}#2\noexpand\@@}\@tempa}
\def\newcmykcolorx#1#2 #3 #4 #5\@@{%
  \xglobal\definecolor{#1}{cmyk}{#2,#3,#4,#5}}
%
\def\newhsbcolor#1#2{%
  \expandafter\gdef\csname #1\endcsname{\color{#1}}%  HV 2004-03-31
  \edef\@tempa{\noexpand\newhsbcolorx{#1}#2\noexpand\@@}\@tempa}
\def\newhsbcolorx#1#2 #3 #4\@@{%
  \xglobal\definecolor{#1}{hsb}{#2,#3,#4}}
%
\definecolor{black}{gray}{0}
\definecolor{darkgray}{gray}{.25}
\definecolor{gray}{gray}{.5}
\definecolor{lightgray}{gray}{.75}
\definecolor{white}{gray}{1}
\definecolor{red}{rgb}{1,0,0}
\definecolor{green}{rgb}{0,1,0}
\definecolor{blue}{rgb}{0,0,1}
%\definecolor{yellow}{rgb}{1,1,0}
%\definecolor{cyan}{rgb}{0,1,1}
%\definecolor{magenta}{rgb}{1,0,1}
\definecolor{yellow}{cmyk}{0,0,1,0}
\definecolor{cyan}{cmyk}{1,0,0,0}
\definecolor{magenta}{cmyk}{0,1,0,0}
%
\renewcommand*\black{\color{black}}
\renewcommand*\darkgray{\color{darkgray}}
\renewcommand*\gray{\color{gray}}
\renewcommand*\lightgray{\color{lightgray}}
\renewcommand*\white{\color{white}}
\renewcommand*\blue{\color{blue}}
\renewcommand*\red{\color{red}}
\renewcommand*\green{\color{green}}
\renewcommand*\yellow{\color{yellow}}
\renewcommand*\magenta{\color{magenta}}
\renewcommand*\cyan{\color{cyan}}
%
\AtBeginDocument{%
  \psset{fillcolor=white}%      hv 0.33
  \let\pst@endcolor=\relax%
%  \let\pst@color=\relax%
% LaTeX used `\color@endgroup' instead. RN 2004-05-06
}
%
\endinput
%%
%% End of file `pstricks.sty'.
